package com.kedi.journalismcenter.write.dao.mapper;


import java.util.Map;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

/**
 * 
 *
 * @author: 	陈辽逊
 * @date: 		2019/7/23 17:00
 */
@Mapper
public interface PcHeadlineMapper {
		
	
	/**
	 * 					国内新闻信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Insert("INSERT homenews"  
			+"(title,content,publishtime,publishman,checker,status,cover_image) "  
			+"VALUE "  
			+"((#{map.title}),(#{map.content}),(#{map.publishtime}),(#{map.publishman}),(#{map.checker}),(#{map.status}),(#{map.coverimage}))")  
	int ihomenews(@Param("map")Map map);
	
	/**
	 * 					根据id修改国内新闻信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Update("UPDATE homenews "
			+"SET "   
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), "  
			+"content = (CASE WHEN (#{map.content}) IS NULL THEN content ELSE (#{map.content}) END), "  
			+"publishtime = (CASE WHEN (#{map.publishtime}) IS NULL THEN publishtime ELSE (#{map.publishtime}) END), "  
			+"publishman = (CASE WHEN (#{map.publishman}) IS NULL THEN publishman ELSE (#{map.publishman}) END), "  
			+"checker = (CASE WHEN (#{map.checker}) IS NULL THEN checker ELSE (#{map.checker}) END), "  
			+"status = (CASE WHEN (#{map.status}) IS NULL THEN status ELSE (#{map.status}) END), "  
			+"cover_image = (CASE WHEN (#{map.coverimage}) IS NULL THEN cover_image ELSE (#{map.coverimage}) END) "  
			+"WHERE homenews_id = (#{map.homenewsid});")
	int homenews(@Param("map")Map map);	
	
	/**
	 * 					创建国内新闻图片资源信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Insert("INSERT homesource"  
			+"(homenews_id,url,class,width,height) "  
			+"VALUE "  
			+"((#{map.homenewsid}),(#{map.url}),(#{map.class}),(#{map.width}),(#{map.height}))") 
	int ihomesource(@Param("map")Map map);
	
	/**
	 * 					根据id修改国内新闻图片资源信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Update("UPDATE homesource  "  
			+"SET  "  
			+"homenews_id = (CASE WHEN (#{map.homenews_id}) IS NULL THEN homenews_id ELSE (#{map.homenews_id}) END), "  
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), "  
			+"class = (CASE WHEN (#{map.class}) IS NULL THEN class ELSE (#{map.class}) END), "  
			+"width = (CASE WHEN (#{map.width}) IS NULL THEN width ELSE (#{map.width}) END), "  
			+"height = (CASE WHEN (#{map.height}) IS NULL THEN height ELSE (#{map.height}) END) "  
			+"WHERE homesource_id = (#{map.homesourceid});")
	int homesource(@Param("map")Map map);
	
	/**
	 * 					创建国际新闻信息
	 * @param		 	map
	 * @return			返回一个封装的对象internationalnews
	 */
	@Insert("INSERT internationalnews "  
			+"(title,content,publishtime,publishman,checker,status,cover_image) "  
			+"VALUE "  
			+"((#{map.title}),(#{map.content}),(#{map.publishtime}),(#{map.publishman}),(#{map.checker}),(#{map.status}),(#{map.coverimage}))")  
	int iinternationalnews(@Param("map")Map map);
	
	/**
	 * 					根据id修改国际新闻信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	
	@Update("UPDATE internationalnews  "  
			+"SET "  
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), "  
			+"content = (CASE WHEN (#{map.content}) IS NULL THEN content ELSE (#{map.content}) END), "  
			+"publishtime = (CASE WHEN (#{map.publishtime}) IS NULL THEN publishtime ELSE (#{map.publishtime}) END), "  
			+"publishman = (CASE WHEN (#{map.publishman}) IS NULL THEN publishman ELSE (#{map.publishman}) END), "  
			+"checker = (CASE WHEN (#{map.checker}) IS NULL THEN checker ELSE (#{map.checker}) END), "  
			+"status = (CASE WHEN (#{map.status}) IS NULL THEN status ELSE (#{map.status}) END), "  
			+"cover_image = (CASE WHEN (#{map.coverimage}) IS NULL THEN cover_image ELSE (#{map.coverimage}) END) "  
			+"WHERE internews_id = (#{map.internewsid});")
	int internationalnews(@Param("map")Map map);	
	
	/**
	 * 					创建国际新闻图片资源信息
	 * @param		 	map				
	 * @return			返回一个封装的对象internationalnews
	 */
	@Insert("INSERT intersource "  
			+"(internews_id,url,class,width,height) "  
			+"VALUE "  
			+"((#{map.internewsid}),(#{map.url}),(#{map.class}),(#{map.width}),(#{map.height}))") 
	int iintersource(@Param("map")Map map);		
	
	/**
	 * 					根据id修改国际新闻图片资源信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Update("UPDATE intersource  "  
			+"SET  "  
			+"internews_id = (CASE WHEN (#{map.internewsid}) IS NULL THEN internews_id ELSE (#{map.internewsid}) END), "  
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), "  
			+"class = (CASE WHEN (#{map.class}) IS NULL THEN class ELSE (#{map.class}) END), "  
			+"width = (CASE WHEN (#{map.width}) IS NULL THEN width ELSE (#{map.width}) END), "  
			+"height = (CASE WHEN (#{map.height}) IS NULL THEN height ELSE (#{map.height}) END) "  
			+"WHERE intersouce_id = (#{map.intersouceid});")
	int intersource(@Param("map")Map map);
	
	/**
	 * 					创建省内信息
	 * @param		 	map
	 * @return			返回一个封装的对象provincialnews
	 */
	@Insert("INSERT provincialnews "  
			+"(title,content,publishtime,publishman,checker,status,cover_image) "  
			+"VALUE "  
			+"((#{map.title}),(#{map.content}),(#{map.publishtime}),(#{map.publishman}),(#{map.checker}),(#{map.status}),(#{map.coverimage}))")  
	int iprovincialnews(@Param("map")Map map);
	
	/**
	 * 					根据id修改省内新闻信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Update("UPDATE provincialnews  "  
			+"SET " 
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), "  
			+"content = (CASE WHEN (#{map.content}) IS NULL THEN content ELSE (#{map.content}) END), "  
			+"publishtime = (CASE WHEN (#{map.publishtime}) IS NULL THEN publishtime ELSE (#{map.publishtime}) END), "  
			+"publishman = (CASE WHEN (#{map.publishman}) IS NULL THEN publishman ELSE (#{map.publishman}) END), "  
			+"checker = (CASE WHEN (#{map.checker}) IS NULL THEN checker ELSE (#{map.checker}) END), "  
			+"status = (CASE WHEN (#{map.status}) IS NULL THEN status ELSE (#{map.status}) END), "  
			+"cover_image = (CASE WHEN (#{map.coverimage}) IS NULL THEN cover_image ELSE (#{map.coverimage}) END) "  
			+"WHERE provincial_id = (#{map.provincialid});")
	int provincialnews(@Param("map")Map map);	
	
	/**
	 * 					创建省内图片资源信息
	 * @param		 	map
	 * @return			返回一个封装的对象provincialnews
	 */
	@Insert("INSERT provsource "  
			+"(provincial_id,url,class,width,height) "  
			+"VALUE "  
			+"((#{map.provincialid}),(#{map.url}),(#{map.class}),(#{map.width}),(#{map.height}))") 
	int iprovsource(@Param("map")Map map);		
	
	/**
	 * 					根据id修改省内新闻图片资源信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Update("UPDATE provsource  "  
			+"SET  "  
			+"provincial_id = (CASE WHEN (#{map.provincialid}) IS NULL THEN provincial_id ELSE (#{map.provincialid}) END), "  
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), "  
			+"class = (CASE WHEN (#{map.class}) IS NULL THEN class ELSE (#{map.class}) END), "  
			+"width = (CASE WHEN (#{map.width}) IS NULL THEN width ELSE (#{map.width}) END), "  
			+"height = (CASE WHEN (#{map.height}) IS NULL THEN height ELSE (#{map.height}) END) "  
			+"WHERE prov_id = (#{map.provid});")
	int provsource(@Param("map")Map map);
	
	/**
	 * 					创建老年新闻信息
	 * @param		 	map
	 * @return			返回一个封装的对象agenews
	 */
	@Insert("INSERT age_news "  
			+"(title,content,publishtime,publishman,checker,status,cover_image) "  
			+"VALUE "  
			+"((#{map.title}),(#{map.content}),(#{map.publishtime}),(#{map.publishman}),(#{map.checker}),(#{map.status}),(#{map.coverimage}))")  
	int iagenews(@Param("map")Map map);
	
	/**
	 * 					根据id修改老年新闻信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Update("UPDATE age_news  "  
			+"SET " 
			+"title = (CASE WHEN (#{map.title}) IS NULL THEN title ELSE (#{map.title}) END), "  
			+"content = (CASE WHEN (#{map.content}) IS NULL THEN content ELSE (#{map.content}) END), "  
			+"publishtime = (CASE WHEN (#{map.publishtime}) IS NULL THEN publishtime ELSE (#{map.publishtime}) END), "  
			+"publishman = (CASE WHEN (#{map.publishman}) IS NULL THEN publishman ELSE (#{map.publishman}) END), "  
			+"checker = (CASE WHEN (#{map.checker}) IS NULL THEN checker ELSE (#{map.checker}) END), "  
			+"status = (CASE WHEN (#{map.status}) IS NULL THEN status ELSE (#{map.status}) END), "  
			+"cover_image = (CASE WHEN (#{map.coverimage}) IS NULL THEN cover_image ELSE (#{map.coverimage}) END) "  
			+"WHERE agenews_id = (#{map.agenewsid});")
	int agenews(@Param("map")Map map);	
	
	/**
	 * 					创建老年新闻图片资源信息
	 * @param		 	map
	 * @return			返回一个封装的对象agenews
	 */
	@Insert("INSERT agenews_source "  
			+"(agenews_id,url,class,width,height) "  
			+"VALUE "  
			+"((#{map.agenewsid}),(#{map.url}),(#{map.class}),(#{map.width}),(#{map.height}))") 
	int iagenewssource(@Param("map")Map map);		
	
	/**
	 * 					根据id老年新闻图片资源信息
	 * @param		 	map
	 * @return			返回一个封装的对象homenews
	 */
	@Update("UPDATE agenews_source  "  
			+"SET  "  
			+"agenews_id = (CASE WHEN (#{map.agenewsid}) IS NULL THEN agenews_id ELSE (#{map.agenewsid}) END), "  
			+"url = (CASE WHEN (#{map.url}) IS NULL THEN url ELSE (#{map.url}) END), "  
			+"class = (CASE WHEN (#{map.class}) IS NULL THEN class ELSE (#{map.class}) END), "  
			+"width = (CASE WHEN (#{map.width}) IS NULL THEN width ELSE (#{map.width}) END), "  
			+"height = (CASE WHEN (#{map.height}) IS NULL THEN height ELSE (#{map.height}) END) "  
			+"WHERE agesource_id = (#{map.agesourceid});")
	int agenewssource(@Param("map")Map map);
	
}	
	
